package com.bdqn.design.computer;

import com.bdqn.design.computer.impl.AddComputer;
import com.bdqn.design.computer.impl.DivComputer;
import com.bdqn.design.computer.impl.MulComputer;
import com.bdqn.design.computer.impl.SubComputer;

/**
 * SimpleComputerFactory
 *
 * @author LILIBO
 * @since 2025/1/6
 */
public class SimpleComputerFactory {

    /**
     * 获取Computer实例的简单工厂
     *
     * @param op 运算符
     * @return
     */
    public static Computer getInstance(String op) {
        switch (op) {
            case "+":
                return new AddComputer();
            case "-":
                return new SubComputer();
            case "*":
                return new MulComputer();
            case "/":
                return new DivComputer();
            default:
                throw new RuntimeException("无效的算法类型：" + op);
        }
    }

}
